package com.fx.service.impl;

import cn.hutool.core.date.DateUtil;
import com.fx.entity.AdminTempUser;
import com.fx.entity.SysUser;
import com.fx.entity.WxConfig;
import com.fx.mapper.WxConfigMapper;
import com.fx.service.WxConfigService;
import com.fx.util.IdWorker;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class WxConfigServiceImpl implements WxConfigService {
    @Autowired
    private WxConfigMapper wxConfigMapper;
    @Autowired
    IdWorker idWorker;

    @Override
    public WxConfig getById(String flId) {
        return wxConfigMapper.getById(flId);
    }

    @Override
    public List<WxConfig> getList(Map<String, Object> map) {
        return wxConfigMapper.queryList(map);
    }

    @Override
    public int getCount(Map<String, Object> map) {
        return wxConfigMapper.queryCount(map);
    }

    @Override
    public int save(WxConfig wxConfig) {
        wxConfig.setFlCreator(((AdminTempUser) SecurityUtils.getSubject().getPrincipal()).getFlName());
        wxConfig.setFlId(String.valueOf(idWorker.nextId()));
        wxConfig.setFlCreatedTime(DateUtil.now());
        return wxConfigMapper.save(wxConfig);
    }

    @Override
    public int updateById(WxConfig wxConfig) {
        return wxConfigMapper.updateById(wxConfig);
    }

    @Override
    public int remove(String flId) {
        return wxConfigMapper.remove(flId);
    }

    @Override
    public int batchRemove(String[] flIds) {
        return wxConfigMapper.batchRemove(flIds);
    }

}
